using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Hermes.Framework.Implementation;
using Hermes.Framework.FileSystem;
using Hermes.Framework.Implementation.File;
using Hermes.Framework.FileSystem.Local;

namespace Hermes.Framework.Test
{
    public class FileCopyTestForObjectiveExist : ObjectiveExistTest
    {
        protected string from, to;

        public FileCopyTestForObjectiveExist()
        {
            this.from = @"file://E:\Visual Studio 2005\Projects\Sact Framework\Hermes.Framework.Test\Resources\source.txt";
            this.to = @"file://E:\Visual Studio 2005\Projects\Sact Framework\Hermes.Framework.Test\Resources\To\source.txt";
        }

        protected override void Operation()
        {
            SimpleResourceManager resourceManager = new SimpleResourceManager();
            LocalFileSystem localFileSystem = new LocalFileSystem();

            TxFileCopy copy = new TxFileCopy(from, to);
            copy.ResourceManager = resourceManager;
            copy.FileSystem = localFileSystem;

            copy.Copy();
            thisWriteTime = File.GetLastWriteTime(@"E:\Visual Studio 2005\Projects\Sact Framework\Hermes.Framework.Test\Resources\To\source.txt");
        }

        protected override string GetObjective()
        {
            return @"E:\Visual Studio 2005\Projects\Sact Framework\Hermes.Framework.Test\Resources\To\source.txt";
        }

        protected override bool VerifyCommitOperation()
        {
            return this.thisWriteTime.CompareTo(this.lastWriteTime) > 0;
        }

        protected override bool VerifyRollbackOperation()
        {
            return this.thisWriteTime.CompareTo(this.lastWriteTime) == 0;
        }
    }
}
